<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<style>
.ui-widget-header {
    background: url("{{url:base}}media/css/jquery.ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png") repeat-x scroll 50% 50% #CCCCCC !important;
    border: 1px solid #AAAAAA !important;
    color: #222222 !important;
    font-weight: bold !important;
}
.ui-widget {
   font-size: 0.8em !important;
}
</style>

<?php 
	$ci = &get_instance();
	$USER = getAccountUserObject(true);
	$escort_id = intval($this->input->get('escort_id',TRUE));
	$ESCORT = $ci->escort_entity->init('id',$escort_id);
	$LOCKED = $ci->locked_escort_entity->init('escort_id', $ESCORT->getId());
	
	$language_array = array_filter( explode(',',$ESCORT->getLanguageIds()) );
	$languageOptionArray = getLanguagesSite_ioc();
	$breastsSizeOptionArray = getBreastsSizeOptionData_ioc();
	$penisSizeOptionArray = getPenisSizeOptionData_ioc();
?>

<form action="<?php echo site_url('agent/escort/submit_personal_info');?>" name="submit_personal_info" id="submit_personal_info" method="post" enctype="multipart/form-data" >
	<input type="hidden" name="escort_id" value="<?php echo $escort_id;?>" />
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left">
			<span><?php echo language_translate('personal_info_sex');?></span>
			<div class="help-text" title="<?php echo language_translate('personal_info_sex_hint');?>"></div>
		</div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<?php echo form_dropdown('personal_info_sex_id', getSexOptionData_ioc(), array($ESCORT->getSex()) , 'id="personal_info_sex_id" class="custom"' );?>
			</div>
			<div class="input-box">
				<input type="checkbox" onoff="1" value="1" name="personal_info_public_sex" class="custom" 
					<?php echo $ESCORT->getPublicSex() == 1 ? "checked='checked'":''; ?> />
			</div>
			<?php if($LOCKED->getLockedSex() == 1):?>
				<div class="locked"></div>
			<?php endif;?>	
			<div class="clear"></div>
		</div>
		<div class="clear"></div>
	</div>
	<!--
	<div id="female_info">
		<div class="dashboard-info-wrapper">
			<div class="dashboard-info-left"><span><?php //echo language_translate('personal_info_breasts_size');?></span></div>
			<div class="dashboard-info-right">
				<div class="select-box">
					<?php //echo form_dropdown('personal_info_breasts_size_id', getBreastsSizeOptionData_ioc(), array($ESCORT->getBreastsSizeId()) , 'id="personal_info_breasts_size_id" class="custom"' );?>
				</div>
				<div class="input-box">
					<input type="checkbox" onoff="1" value="1" name="personal_info_public_breasts_size" class="custom" 
						<?php //echo $ESCORT->getPublicBreastsSize() == 1 ? "checked='checked'":''; ?> />
				</div>
				
				<div class="clear"></div>
			</div>
			<div class="clear"></div>
		</div>
	</div>
	
	<div id="male_info">
		<div class="dashboard-info-wrapper">
			<div class="dashboard-info-left"><span><?php //echo language_translate('personal_info_penis_size');?></span></div>
			<div class="dashboard-info-right">
				<div class="select-box">
					<?php //echo form_dropdown('personal_info_penis_size_id', getPenisSizeOptionData_ioc(), array($ESCORT->getPenisSizeId()) , 'id="personal_info_penis_size_id" class="custom"' );?>
				</div>
				<div class="input-box">
					<input type="checkbox" onoff="1" value="1" name="personal_info_public_penis_size" class="custom" 
						<?php //echo $ESCORT->getPublicPenisSize() == 1 ? "checked='checked'":''; ?> />
				</div>
				<div class="clear"></div>
			</div>
			<div class="clear"></div>
		</div>
	</div>
	-->
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left">
			<span><?php echo language_translate('personal_info_sexual_orientation');?></span>
			<div class="help-text" title="<?php echo language_translate('personal_info_sexual_orientation_hint');?>"></div>
		</div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<?php echo form_dropdown('personal_info_sexual_orientation_id', getSexualOrientationData_ioc(), array($ESCORT->getSexualOrientationId()) , 'id="personal_info_sexual_orientation_id" class="custom"' );?>
			</div>
			<div class="input-box">
				<input type="checkbox" onoff="1" value="1" name="personal_info_public_sexual_orientation" class="custom" 
				<?php echo $ESCORT->getPublicSexualOrientation() == 1 ? "checked='checked'":''; ?> />
			</div>
			<?php if($LOCKED->getLockedSexualOrientation() == 1):?>
				<div class="locked"></div>
			<?php endif;?>
			
			<div class="clear"></div>
		</div>
		<div class="clear"></div>
	</div>
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left">
			<span><?php echo language_translate('personal_info_birthdate');?></span>
			<div class="help-text" title="<?php echo language_translate('personal_info_birthdate_hint');?>"></div>
		</div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<input class="text-box" type="text" value="<?php echo $ESCORT->getBirthDate() ? sysDateFormat($ESCORT->getBirthDate(), DATE_FORMAT):'';?>" name="personal_info_birthdate" id="personal_info_birthdate" />
			</div>
			<div class="input-box">
				<input type="checkbox" onoff="1" value="1" name="personal_info_public_birthdate" class="custom" 
				<?php echo $ESCORT->getPublicBirthDate() == 1 ? "checked='checked'":''; ?> />
			</div>
			<?php if($LOCKED->getLockedBirthDate() == 1):?>
				<div class="locked"></div>
			<?php endif;?>
		</div>
		<div class="clear"></div>
	</div>
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left">
			<span><?php echo language_translate('personal_info_languages');?></span>
			<div class="help-text" title="<?php echo language_translate('personal_info_languages_hint');?>"></div>
		</div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<?php echo multi_checkbox('personal_info_languages[]', getLanguagesData_ioc(), $language_array, "style='width:108px;height:100px;float:left;overflow:auto;border:1px solid #222222;'");?>
			</div>
			<div class="input-box">
				<input type="checkbox" onoff="1" value="1" name="personal_info_public_languages" class="custom" 
				<?php echo $ESCORT->getPublicLanguageIds() == 1 ? "checked='checked'":''; ?> />
			</div>
			<?php if($LOCKED->getLockedLanguageIds() == 1):?>
				<div class="locked"></div>
			<?php endif;?>
			
			<div class="clear"></div>
		</div>
		<div class="clear"></div>
	</div>

<!-- 
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php //echo language_translate('personal_info_country');?></span></div>
		<div class="dashboard-info-right">
				<div class="select-box">
					<?php //if($USER->getCountryId() == 0): ?>
						<?php //echo form_dropdown('country_id', getCountryData_ioc(), array($ESCORT->getCountryId()), 'id="country_id" class="custom"');?>
					<?php //else: ?>
						<?php //echo form_dropdown('country_id', getCountryData_ioc($USER->getCountryId()), array($ESCORT->getCountryId()), 'id="country_id" class="custom"');?>
					<?php //endif; ?>
				</div>
			<div class="input-box">
				<input type="checkbox" onoff="1" value="1" name="personal_info_public_country" class="custom" 
				<?php //echo $ESCORT->getPublicCountry() == 1 ? "checked='checked'":''; ?> />
			</div>
			<?php //if($LOCKED->getLockedCountry() == 1):?>
				<div class="locked"></div>
			<?php //endif;?>
			<div class="clear"></div>
		</div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php //echo language_translate('registration_page_state');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box" id="slb_state_id">
				<?php //if($USER->getStateId() == 0): ?>
					<?php //echo form_dropdown('state_id', getStateData_ioc($ESCORT->getCountryId()), array($ESCORT->getStateId()) , 'id="state_id" class="custom"' );?>
				<?php //else: ?>
					<?php //echo form_dropdown('state_id', getStateData_ioc($ESCORT->getCountryId(),$USER->getStateId()), array($ESCORT->getStateId()) , 'id="state_id" class="custom"' );?>
				<?php //endif; ?>
			</div>
			<?php //echo loader_image_s('id="slb_state_id_loader" class="hidden"');?>
		 </div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php //echo language_translate('registration_page_province');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box" id="slb_province_id" >
				<?php //if($USER->getProvinceId() == 0): ?>
					<?php //echo form_dropdown('province_id', getProvinceData_ioc($ESCORT->getCountryId(),$ESCORT->getStateId()), array($ESCORT->getProvinceId()) , 'id="province_id" class="custom"' );?>
				<?php //else: ?>
					<?php //echo form_dropdown('province_id', getProvinceData_ioc($ESCORT->getCountryId(),$ESCORT->getStateId(),$USER->getProvinceId()), array($ESCORT->getProvinceId()) , 'id="province_id" class="custom"' );?>
				<?php //endif; ?>
			</div>
			<?php //echo loader_image_s('id="slb_province_id_loader" class="hidden"');?>
		 </div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"><span><?php //echo language_translate('registration_page_city');?></span></div>
		<div class="dashboard-info-right">
			<div class="select-box" id="slb_city_id">
				<?php //if($USER->getCityId() == 0): ?>
					<?php //echo form_dropdown('city_id', getCityData_ioc($ESCORT->getCountryId(),$ESCORT->getStateId(),$ESCORT->getProvinceId()), array($ESCORT->getCityId()) , 'id="city_id" class="custom"' );?>
				<?php //else: ?>
					<?php //echo form_dropdown('city_id', getCityData_ioc($ESCORT->getCountryId(),$ESCORT->getStateId(),$ESCORT->getProvinceId(),$USER->getCityId()), array($ESCORT->getCityId()) , 'id="city_id" class="custom"' );?>
				<?php //endif ;?>
			</div>
			<?php //echo loader_image_s('id="slb_city_id_loader" class="hidden"');?>
		 </div>
		<div class="clear"></div>
	</div>
 -->	
 
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left">
			<span><?php echo language_translate('personal_info_profession');?></span>
			<div class="help-text" title="<?php echo language_translate('personal_info_profession_hint');?>"></div>
		</div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<?php echo form_dropdown('profession_id', getProfessionData_ioc(), array($ESCORT->getProfessionId()) , 'id="profession_id" class="custom"' );?>
			</div>
			<div class="input-box">
				<input type="checkbox" onoff="1" value="1" name="personal_info_public_profession" class="custom" 
				<?php echo $ESCORT->getPublicProfession() == 1 ? "checked='checked'":''; ?> />
			</div>
			<?php if($LOCKED->getLockedProfession() == 1):?>
				<div class="locked"></div>
			<?php endif;?>
		 </div>
		<div class="clear"></div>
	</div>
	
	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left">
			<span><?php echo language_translate('borncountry_label');?></span>
			<div class="help-text" title="<?php echo language_translate('borncountry_label_hint');?>"></div>
		</div>
		<div class="dashboard-info-right">
			<div class="select-box">
				<?php 
					$dfC  = ($ESCORT->getBornCountryId() != 0)?$ESCORT->getBornCountryId():$USER->getBornCountryId();
					echo form_dropdown('borncountry_id', getBornCountryData_ioc(), array($dfC) , 'id="borncountry_id" class="custom"' );
				?>
			</div>
			<div class="input-box">
				<input type="checkbox" onoff="1" value="1" name="personal_info_public_borncountry" class="custom" 
				<?php echo $ESCORT->getPublicBorncountry() == 1 ? "checked='checked'":''; ?> />
			</div>
			<?php if($LOCKED->getLockedBornCountry() == 1):?>
				<div class="locked"></div>
			<?php endif;?>
		 </div>
		<div class="clear"></div>
	</div>
	
	<div id="description-tabs-wrapper">
		<?php echo loader_image_s('id="personal_languages_loader" class="hidden"');?>
		<div id="description-tabs">
			<!--
			<?php if((getLanguagesSiteString_ioc())):?>
				<ul>
					<?php foreach( array_filter(explode(',',getLanguagesSiteString_ioc())) as $item):?>
						<li><a href="#des-tabs-lang-<?php echo $item;?>"><?php echo $languageOptionArray[$item][0];?></a></li>
					<?php endforeach; ?>
					<li><a href="#des-tabs-lang-00">&nbsp;</a></li>
				</ul>
				<?php foreach( array_filter(explode(',',getLanguagesSiteString_ioc())) as $item):?>
					<div id="des-tabs-lang-<?php echo $item;?>">
						<textarea rows="10" cols="58" name="personal_info_language_<?php echo $item;?>"><?php echo $ESCORT->getDescription($item,$ESCORT->getId());?></textarea>
					</div>
				<?php endforeach; ?>
				<div id="des-tabs-lang-00">
					&nbsp; 
				</div>
			<?php endif; ?>
			-->
			<?php $this->load->view("agent/tabs/async_partial_personal_languages_textares"); ?>
		</div>	
		<!-- <div class="help-text" title="<?php echo language_translate('personal_info_desc_hint');?>"></div>	-->
	</div> 

	<div class="dashboard-info-wrapper">
		<div class="dashboard-info-left"> 
			<div class="select-box">
				<input type="submit" class="save-button" value="<?php echo language_translate('personal_info_save');?>" /> 
			</div>
		 </div>
		 <div class="dashboard-info-right">
			<?php echo loader_image("id='personal_info_loader_image' class='hidden'");?>
		</div>
		<div class="clear"></div>
	</div>	 
	
	<div class="dashboard-info-wrapper">
		<div id="update-message"><?php echo language_translate('update_successfully_message');?></div>
		<div class="clear"></div>
	</div>
</form>

<script type="text/javascript">
$(document).ready(function() {
	$('.descClsTextarea').live('keyup',function(){
		$id = $(this).attr('id');
		$('#isChangeDescFlag').attr('value',1);
		
		$('.sourcelanguage').attr('checked',false);
		$('#trans_mode_id_'+$id).attr('checked',false);
		$('#lang_source_'+$id).attr('checked',true);
	});
	$('.autotranslate,.sourcelanguage').live('change',function(){
		$('#isChangeDescFlag').attr('value',1);
	});
});

$(document).ready(function() {
/*
	$('#personal_info_sex_id').bind('change',function(){
		changeSexOption($(this).val());
	});
	changeSexOption($('#personal_info_sex_id').val());
	
	$('#country_id').live('change',function(){
		changeCountry_slb($('#country_id').val());
	});
	$('#state_id').live('change',function(){
		changeState_slb($('#state_id').val(),$('#country_id').val());
	});
	$('#province_id').live('change',function(){
		changeProvince_slb($('#state_id').val(),$('#province_id').val(),$('#country_id').val());
	});
	*/
	$('.help-text[title]').qtip({ style: { name: 'dark', tip: true } });
});

function changeSexOption(id){
	$('#female_info,#male_info').hide();
	if(id == <?php echo SEX_OPTION_FEMALE_ID;?>){
		$('#female_info').show();
	}
	if(id == <?php echo SEX_OPTION_MALE_ID;?>){
		$('#male_info').show();
	}
}

$(document).ready(function() {	
	$('#personal_info_birthdate').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: DATE_FORMAT,
		yearRange: 'c-40:c'
	}); 
	var options = { 
		beforeSubmit:  validateB4SubmitPersonalInfo,  
		success:       processAfterRespondingPersonalInfo   
	};	
	$('#submit_personal_info').ajaxForm(options); 
	//$('input[name=personal_info_languages\\[\\]]').bind('change',function(){
	//	loadMultiLang();
	//});
});	

function loadMultiLang(){
	$lang_arr = getMultiCheckbox('personal_info_languages');
	$lang_ids = $lang_arr ? $lang_arr.join(','):'';
	$('#personal_languages_loader').show();
	$.get(BASE_URI+'agent/async/loadAsyncPersonalLanguages',{lang_ids:$lang_ids,escort_id:<?php echo $escort_id;?>},function(res){
		$('#description-tabs-wrapper').html(res);
		$("#description-tabs").tabs({
			select: function(event, ui) {
				//alert(ui.index);
				$("#description-tabs > ul.ui-tabs-nav li").removeClass("ui-tabs-next-to-selected");
				li = $("#description-tabs > ul.ui-tabs-nav li").get(ui.index + 1)
				$(li).addClass("ui-tabs-next-to-selected");
				if(ui.index != 0){
					liFirst = $("#description-tabs > ul.ui-tabs-nav li").get(0)
					$(liFirst).addClass("ui-tabs-first-non-selected");
				}else{
					liFirst = $("#description-tabs > ul.ui-tabs-nav li").get(0)
					$(liFirst).removeClass("ui-tabs-first-non-selected");
				}
				
				if(ui.index >= $("#description-tabs > ul.ui-tabs-nav li").length-2){
					liLast = $("#description-tabs > ul.ui-tabs-nav li").get($("#description-tabs > ul.ui-tabs-nav li").length-1);
					$(liLast).removeClass("ui-tabs-last-non-selected");
					$(liLast).addClass("ui-tabs-last-selected");	
				}else{
					liLast = $("#description-tabs > ul.ui-tabs-nav li").get($("#description-tabs > ul.ui-tabs-nav li").length-1);
					$(liLast).addClass("ui-tabs-last-non-selected");
				}
			}
		});
		$('.help-text[title]').qtip({ style: { name: 'dark', tip: true } });
		$('#description-tabs input:checkbox:not([onoff]).custom').checkbox({cls:'jquery-safari-checkbox'});
		$('#description-tabs input[onoff]:checkbox.custom').checkbox();
	});
}

function validateB4SubmitPersonalInfo(formData, jqForm, options){
	$('#personal_info_loader_image').show();
	return true;
}

function processAfterRespondingPersonalInfo(responseText, statusText, xhr, $form) {
	$('#personal_info_loader_image').hide();	
	if(responseText == 'ok'){
		loadMultiLang();
		updatedShow();
	}else{
		debug(responseText);
	}
}

function changeCountry_slb($country_id){
	$('#slb_state_id, #slb_province_id, #slb_city_id').html('<select class="custome"></select>');
	$('select.custome').customStyle();
	$('#slb_state_id_loader, #slb_province_id_loader, #slb_city_id_loader').show();
	$.post(BASE_URI+'registration/changeCountry_async',{country_id:$country_id},function(res){
		$('#slb_state_id_loader').hide();
		$('#slb_state_id').html(res);
		$('select#state_id').customStyle();
		$firtElementValue = $('#state_id').children().first().val();
		changeState_slb($firtElementValue,$country_id);
	});
}

function changeState_slb($state_id,$country_id){
	$('#slb_province_id, #slb_city_id').html('<select class="custome"></select>');
	$('select.custome').customStyle();
	$('#slb_province_id_loader, #slb_city_id_loader').show();
	$.post(BASE_URI+'registration/changeState_async',{state_id:$state_id,country_id:$country_id},function(res){
		$('#slb_province_id_loader').hide();
		$('#slb_province_id').html(res);
		$('select#province_id').customStyle();
		$firtElementValue = $('#province_id').children().first().val();
		changeProvince_slb($state_id,$firtElementValue,$country_id);
	});
}

function changeProvince_slb($state_id,$province_id,$country_id){
	$('#slb_city_id').html('<select class="custome"></select>');
	$('select.custome').customStyle();
	$('#slb_city_id_loader').show();
	$.post(BASE_URI+'registration/changeProvince_async',{state_id:$state_id,province_id:$province_id,country_id:$country_id},function(res){
		$('#slb_city_id_loader').hide();
		$('#slb_city_id').html(res);
		$('select#city_id').customStyle();
	});
}

</script>		